<template>
  <div>
    <div>data:{{data}}
    <input type="text" placeholder="按回车添加数字" 
    v-model="addValue"
    @keypress.enter="add">{{addValue}}
    </div>
    <div>Sum of numbers {{sums}}</div>
  </div>
</template>

<script setup>
import { ref,computed } from 'vue'
const data = ref([1,2,3,45,6])
const addValue = ref()
let add = () => {
  data.value.push(Number(addValue.value))
  addValue.value = ''
}
const sums = computed(()=>{
  return data.value.reduce((a,b)=>{
    return a + b
  })
})
</script>

<style scoped>

</style>